package kkb.IOTest;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

//转换流测试  文件输入流
public class InputStreamReaderTest {

    public static void main(String[] args) throws IOException {

        //字节流 读取文件
        FileInputStream fileInputStream = new FileInputStream("D://fileoutputstream.txt");

        //把字节流 装饰成字符流
        //参数1：要转换的 字节流
        //参数2：编码格式
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");
//读取一个字符
//        while (true){
//            int read = inputStreamReader.read();
//            if(read == -1)
//                break;
//            System.out.println((char)read);
//        }

        //读取一串字符
        char[] a = new char[50];
        int read = inputStreamReader.read(a);
        System.out.println(new String(a));
        inputStreamReader.close();
    }
}
